package com.gem.eolane.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gem.eolane.entity.PcbOffer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface SurfaceMapper extends BaseMapper<PcbOffer> {
    //根据用户id查询当前用户历史订单
    @Select("select * from pcb_offer where user_id =#{id} order by user_id desc limit #{CURRENT_PAGE},#{PAGE_SIZE}")
    List<PcbOffer> findUid(Integer id,Integer CURRENT_PAGE,Integer PAGE_SIZE);

    //根据当前用户查询历史订单返回页面
    @Select("select * from pcb_offer where id = #{value}")
    List<PcbOffer> finpcblist(String id);

    //根据用户输入的邮箱判断用户是否存在
    @Select("select mail from user where mail= #{value}")
    String finuse(String email);

    //修改用户的密码
    @Update("update user set password = #{password} where mail = #{mail}")
    void upword(String password , String mail);

    //查询当前用户历史订单数量
    @Select("select count(*) from pcb_offer where del_ident=0 and user_id=${value}")
    Integer fcount(Integer id);
}
